package com.cmy.framework.mvvm.mvvm.view

import android.app.Activity
import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.ViewModel
import com.cmy.framework.mvvm.ParameterField
import com.cmy.framework.mvvm.event.UIChangeLiveData
import com.cmy.framework_base.basics.BasicsActivity

/**
 * @name:
 *  BaseActivity
 * @package:
 *  com.cmy.framework.mvvm.mvvm.view
 * @date:
 *  2023/2/1615:33
 * @author
 *    cmy
 * @description
 *
 */
abstract class BaseActivity : BasicsActivity() {

    override fun setWindowConfigure() {
        super.setWindowConfigure()
        registerInit()
        //TODO 暂时不实用弹窗显示，因为Ui反倒变得不好看，没有好的反馈意义
//        registerLoadDialogView(SimpleLoadDialogImp(supportFragmentManager))

    }



    /**
     * UI刷新对应的处理
     */
    protected fun registerUiChange(uiChange: UIChangeLiveData) {

        //关闭页面
        uiChange.finishEvent.observe(this@BaseActivity, observer = {
            finish()
        })

    }


    /**
     * 创建一个VIewModel
     */
    protected  inline fun  <reified VM :ViewModel> createViewModel() :Lazy<VM>{
        return viewModels<VM>()
    }


    /**
     * 注册需要注册的信息
     */
    protected abstract fun registerInit()



}
